<?php

namespace App\weapp\controller;

use App\model\EmployeeModel;
use App\services\Upload;
use App\model\Comment;
use App\model\Post;
use App\model\PostMessage;
use App\model\User;
use App\model\CoinsLog;
use App\model\UserCollectPost;
use App\model\UserViewPostLog;
use App\model\UserZanPost;
use support\Request;

//用户关联接口 需要登录
class EmployeeController extends Controller
{
    /**
     * 用户信息
     */

    public function info(Request $request)
    {
        $user = EmployeeModel::select(['id', 'name', 'avatar_url',  'phone', 'mine_bg'])->find($request->uid);
        if (empty($user)) return error('用户不存在', [], 502);
        $user->login_at = date('Y-m-d H:i:s');
        $user->save();
        return success('用户信息', $user);

    }


    public function setInfo(Request $request)
    {
        $data = $request->only(['avatar_url', 'name', 'phone', 'mine_bg']);
        EmployeeModel::where('id', $request->uid)->update($data);
        return success("更新成功");
    }

}
